<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Wall
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: Core.php 2011-04-26 11:18:13 michael $
 * @author     Michael
 */

/**
 * @category   Application_Extensions
 * @package    Wall
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 */

class Wall_Plugin_Composer_Core extends Core_Plugin_Abstract {
	public function onAttachLink($data) {
		try {
			$viewer = Engine_Api::_ ()->user ()->getViewer ();
			if (Engine_Api::_ ()->core ()->hasSubject ()) {
				$subject = Engine_Api::_ ()->core ()->getSubject ();
				if ($subject->getType () != 'user') {
					$data ['parent_type'] = $subject->getType ();
					$data ['parent_id'] = $subject->getIdentity ();
				}
			}
			
			$link = Engine_Api::_ ()->getApi ( 'links', 'core' )->createLink ( $viewer, $data );
		} catch ( Exception $e ) {
			throw $e;
			return;
		}
		return $link;
	}
}